#!/bin/bash
DATE_STR=$(date -d "1 day ago" +"%Y-%m-%d")
WORK_DIR="/var/log/weblog"

cd $WORK_DIR

if [ -f ./access_log_bmm-web-1-$DATE_STR.txt -a -f ./access_log_bmm-web-2-$DATE_STR.txt ];then
	sort -m -k4 -o ./access_log_bmm-${DATE_STR}.txt ./access_log_bmm-web-1-$DATE_STR.txt ./access_log_bmm-web-2-$DATE_STR.txt
	tar -czf access_log_bmm-${DATE_STR}.tar.gz ./access_log_bmm-${DATE_STR}.txt
	rm -rf *$DATE_STR.txt

else
	echo "cannot find these files at $(date +"%Y-%m-%d")"
fi

exit 0
